/**
 * Created by kevin on 16/12/23.
 */
var Router = require('koa-router')
var UserService = require('../../services/controllers/user.ctrl')

function register(app) {
    var router = new Router({
        prefix: '/user'
    });

    router.get('/', function *(next) {
        var jwt = this.headers['jwt-access-token']
        var abc = yield *UserService.getUser('hc-sales', jwt);

        var users = JSON.parse(abc.body);
        this.body = RES.SUCCESS({rows: users,count: users.length}, '返回sales用户成功', 200)
    });

    app.use(router.routes());
    app.use(router.allowedMethods());
}

module.exports = register;
